package com.wuyb.exception;

import com.wuyb.enums.ErrorCode;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: wyb
 * @Date: 2024/01/08/19:43
 * @Description:
 */
public class NormalException extends RuntimeException {
    /**
     * 错误码
     */
    private final int code;

    public NormalException(int code, String message) {
        super(message);
        this.code = code;
    }

    public NormalException(String message) {
        this(ErrorCode.SYSTEM_ERROR.getCode(), message);
    }

    public NormalException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
    }

    public NormalException(ErrorCode errorCode, String message) {
        super(message);
        this.code = errorCode.getCode();
    }

    public int getCode() {
        return code;
    }
}
